package com.zhouh.golden.web.intercept;

import com.zhouh.golden.web.controller.base.BaseController;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author zhouheng
 */
public class LoginIntercept extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HandlerMethod handlerMethod = (HandlerMethod)handler;

        Object action = handlerMethod.getBean();

        if(!(action instanceof BaseController)){
            throw new Exception("异常");
        }

//        GoldenUserDetails details = (GoldenUserDetails) authentication.getPrincipal();
//        setUserId(details.getUserId());


        return true;
    }

}
